package com.ocom.payconfig.controller;

import com.github.pagehelper.PageInfo;
import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.ccb.GetCcbAccountListRVo;
import com.ocom.common.vo.ccb.GetCcbAccountListVo;
import com.ocom.payconfig.service.CcbAccountService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
public class CcbAccountController {

    @Resource
    private CcbAccountService ccbAccountService;

    /**
     * 5.2 获取建行智慧生活账号明细
     * @param request
     * @return
     */
    @PostMapping(PayConfigUrl.Url_GetCcbAccountList)
    public Result getCcbAccountList (@RequestBody GetCcbAccountListVo request){
        List<GetCcbAccountListRVo> list = ccbAccountService.getCcbAccountList(request.getComId(), request);
        PageInfo<GetCcbAccountListRVo> pageInfo = new PageInfo<>(list);
        HashMap<String, Object> map = new HashMap<>();
        map.put("total",pageInfo.getTotal());
        map.put("list",pageInfo.getList());
        return ResultUtil.success(map);
    }
}
